<template>
	<view class="padding-top-xl margin-top-xl">
		<custom-nav/>
		<view class="flex flex-wrap padding-sm justify-between">
			<company-job-item v-for="item in list" :jobdata="item"/>
		</view>
	</view>
</template>

<script>
import { jobGet } from '../../api/job';
	export default {
		data() {
			return {
				list:[],
				page:1,
				// cateName:'' //分类名称
			};
		},
		onTabItemTap() {
			console.log('点击了底部菜单');
			uni.removeStorage({
				key:'cateName'
			})
		},
		onShow() {
			setTimeout(()=>{
				uni.getStorage({
					key:'cateName',
					success: ({data}) => {
						console.log('分类名称',data);
						this.cateName = data
						this.list = []
						this.page = 1
						this.loadData()
					},
					fail: () => {
						console.log('没有分类名称');
						this.cateName = ''
						this.list = []
						this.page = 1
						this.loadData()
					}
				})
			},200)
		},
		onReachBottom() {
			console.log('触底了');
			this.loadData()
		},
		onPullDownRefresh() {
			console.log('下拉刷新');
			this.list = []
			this.page = 1
			this.loadData()
		},
		
		methods: {
			loadData() {
				jobGet(this.page,this.cateName).then(res=>{
					uni.stopPullDownRefresh() //关闭下拉刷新
					let {results} = res.data
					if(results.length){
						this.list = [
							...this.list,
							...results
						]
						this.page++
						return
					}
					uni.showToast({
						title:'没有更多数据了',
						icon:'none'
					})
				})
			}
		},
	}
</script>

<style lang="scss">

</style>
